package zhoug.demo.zui.ui;

import android.os.Bundle;
import android.widget.Button;
import android.widget.LinearLayout;

import zhoug.zui.valuepair.ZUIKeyValueEditText;
import zhoug.zui.valuepair.ZUIKeyValueSelector;
import zhoug.zui.valuepair.ZUIKeyValueText;
import zhoug.demo.zui.R;

import androidx.appcompat.app.AppCompatActivity;

public class ValuePairActivity extends AppCompatActivity {

    private LinearLayout mContainer;
    private ZUIKeyValueText mKeyValueText;
    private ZUIKeyValueSelector mKeyValueSelect;
    private Button mBtn1;
    private Button mBtn2;
    private ZUIKeyValueEditText mEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_value_pair);
        findViews();
//        EditText editText=new EditText(this);
//        editText.setBackground(new ColorDrawable(Color.RED));
//        editText.setText("常住地");
//        mContainer.addView(editText);

        mBtn1.setOnClickListener(v->{
            mKeyValueText.setError("姓名不能含有非法字符");
            mKeyValueSelect.setError("性别只能取值:男/女");
            mEditText.setError("年龄取值范围[0-100]");
        });
        mBtn2.setOnClickListener(v->{
            mKeyValueText.setError(null);
            mKeyValueSelect.setError("");
            mEditText.setError("");
        });
    }

    private void findViews() {
        mContainer = findViewById(R.id.container);
        mKeyValueText = findViewById(R.id.keyValueText);
        mKeyValueSelect = findViewById(R.id.keyValueSelect);
        mBtn1 = findViewById(R.id.btn1);
        mBtn2 = findViewById(R.id.btn2);
        mEditText = findViewById(R.id.editText);
    }


}